<template>
  <div class="brand-detail">
    <!-- 顶部导航 -->
    <van-sticky class="nav">
      <van-nav-bar class="topNaV" @click-left="onClickLeft" fixed z-index="99999">
        <template #title>
          <p class="title">品牌制造商</p>
        </template>
        <template #left>
          <van-icon name="arrow-left" color="#666666" />
          <p class="left">返回</p>
        </template>
      </van-nav-bar>
    </van-sticky>

    <div class="brand">
      <img :src="title.list_pic_url" alt="" class="title-img" />
      <p class="title-name">{{ title.name }}</p>
      <p class="title-desc">{{ title.simple_desc }}</p>
    </div>

    <div v-if="isShow">
      <!-- 分割线 -->
      <!-- <van-divider class="br" /> -->
      <div class="goods">
        <div
          v-for="item in list"
          :key="item.id"
          class="goods-item"
          @click="goodDetail(item)"
        >
          <img :src="item.list_pic_url" alt="" class="goods-img" />
          <p class="goods-name">{{ item.name }}</p>
          <p class="goods-price">￥{{ item.retail_price }}</p>
        </div>
      </div>
    </div>
    <div v-else class="nodata">
      <div class="text">
        <p>数据库暂无数据...</p>
      </div>
      <div class="box"></div>
    </div>
  </div>
</template>
<script setup>
import { brandDetail } from '@/api/index'
import { ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
const title = ref({})
const list = ref([])
const isShow = ref(true)
const route = useRoute()
const router = useRouter()
brandDetail({ id: route.params.id }).then(res => {
  title.value = res.data
  list.value = res.goodsList
})
const onClickLeft = () => {
  router.back()
}
const goodDetail = (obj) => {
  router.push({ name: 'categoryDetail', params: { id: obj.id } })
}
</script>
<script>
export default {
  name: 'brandDetai'
}
</script>

<style scoped lang="scss">
.brand-detail {
  width: 750px;
  .brand {
    width: 750px;
    margin-top: 90px;
    position: relative;
    .title-img {
      width: 750px;
      height: 326px;
    }
    .title-name {
      position: absolute;
      top: 114px;
      left: 50%;
      transform: translate(-50%);
      border: 4px solid rgba(255, 255, 255, 1);
      height: 50px;
      line-height: 50px;
      text-align: center;
      color: #ffffff;
      padding: 16px;
      font-size: 40px;
    }
    .title-desc {
      margin: 43px auto;
      width: 626px;
      font-size: 28px;
      color: #666666;
      letter-spacing: 0;
      font-weight: 400;
      text-align: left;
    }
  }
}
.brand-list {
  width: 710px;
  margin: 0 auto;
}
.brand-img {
  width: 300px;
  height: 200px;
}
.nav {
  .topNav {
    background-color: #fff;

    .left {
      font-size: 31.2px;
      color: #666666;
      letter-spacing: 0;
      font-weight: 400;
    }

    .title {
      font-size: 36px;
      color: #333333;
      letter-spacing: 0;
      font-weight: 500;
    }
  }
}
.goods {
  //display: flex;
  width: 710px;
  margin: 0 auto;
  overflow: hidden;
  margin-right: 10px;
}
.goods-item {
  //display: flex;
  width: 350px;
  float: left;
  margin-right: 10px;
  .goods-name {
    font-size: 26px;
    color: #333333;
    letter-spacing: 0;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 17px 0 0 0;
    text-align: left;
    line-height: 37px;
    height: 37px;
    padding: 0;
  }
  .goods-img {
    width: 350px;
    height: 340px;
  }

  .goods-price {
    font-size: 26px;
    color: #9e4242;
    letter-spacing: 0;
    font-weight: 400;
    margin: 5px 0 42px 0;
    padding: 0;
    text-align: left;
    line-height: 37px;
    height: 37px;
  }
}
.goods .goods-item:nth-child(2n) {
  margin-right: 0px;
}
.nodata {
  width: 750px;
  overflow: hidden;
  .text {
    margin-top: 122px;
    line-height: 45px;
    height: 45px;
    font-size: 32px;
    color: #999999;
    letter-spacing: 0;
    font-weight: 400;
    text-align: center;
  }
  .box {
    width: 750px;
    height: 750px;
  }
}
</style>
